<html>
<head>
<title>ioctl</title>
<body bgcolor=#ffffff>
<h2 align=center>ioctl</h2>
<h4 align=center>OS/161 Reference Manual</h4>

<h3>Name</h3>
ioctl - miscellaneous device I/O operations

<h3>Library</h3>
Standard C Library (libc, -lc)

<h3>Synopsis</h3>
#include &lt;sys/ioctl.h&gt;<br>
<br>
int<br>
ioctl(int <em>fd</em>, int <em>code</em>, void *<em>data</em>);

<h3>Description</h3>

ioctl performs an object-specific operation <em>code</em> on the
object referred to by the file handle <em>fd</em>. The <em>data</em>
argument may point to supplemental data required or returned by the
operation. The size of buffer required, if any, and other such matters
are operation-specific.
<p>

Traditionally, ioctl is a catchall function for performing operations
that don't fit neatly into any other model.
<p>

The ioctl codes are defined in &lt;kern/ioctl.h&gt;, which should be
included via &lt;sys/ioctl.h&gt; by user-level code. As of this
writing, the base OS/161 system defines no ioctls. However, it may
prove useful to implement some, particularly in connection with some
less conventional possible projects.
<p>

<h3>Return Values</h3>
On success, ioctl returns 0. On error, -1 is returned, and
<A HREF=errno.html>errno</A> is set according to the error
encountered.

<h3>Errors</h3>

The following error codes should be returned under the conditions
given. Other error codes may be returned for other errors not
mentioned here.

<blockquote><table width=90%>
<td width=10%>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>EBADF</td>		<td><em>fd</em> was not a valid file handle.</td></tr>
<tr><td>EIOCTL</td>		<td><em>code</em> was an invalid ioctl for the
				object referenced.</td></tr>
<tr><td>EFAULT</td>		<td><em>data</em> was required by the operation
				requested, but was an invalid pointer.</td></tr>
</table></blockquote>

</body>
</html>
